//Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Eas.WebCrawler.Test.Model {
    /// <summary>
    /// Summary description for WebCrawlerFactoryTest
    /// </summary>
    [TestClass]
    public class WebCrawlerFactoryTest {



        public WebCrawlerFactoryTest() {
            //
            // TODO: Add constructor logic here
            //
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        /// <summary>Executes the TestWebFactoryCreate test.</summary>
        public void TestWebFactoryCreate() {
            using (NMock2.Mockery mockery = new NMock2.Mockery()) {

                try {
                    Eas.WebCrawler.Interfaces.WebCrawlerSettings settings = mockery.NewMock<Eas.WebCrawler.Interfaces.WebCrawlerSettings>();

                    NMock2.Expect.Once.On(settings).GetProperty("CompletedRequestHistory").Will(NMock2.Return.Value(new Eas.WebCrawler.PlugIns.Histories.AlwaysEmptyRequestHistory()));
                    NMock2.Expect.Once.On(settings).GetProperty("RequestPriorityComparer").Will(NMock2.Return.Value(new Eas.WebCrawler.PlugIns.RequestComparers.AlphabeticComparer()));
                    NMock2.Expect.Once.On(settings).GetProperty("StorageFactory").Will(NMock2.Return.Value(new Eas.WebCrawler.PlugIns.TemporaryStorage.MemoryStorageFactory()));
                    NMock2.Expect.Once.On(settings).GetProperty("Selector").Will(NMock2.Return.Value(new Eas.WebCrawler.PlugIns.Selectors.ConstantSelector(false)));
                    NMock2.Expect.Once.On(settings).GetProperty("LinkExtractor").Will(NMock2.Return.Value(new Eas.WebCrawler.PlugIns.LinkExtractors.HtmlLinkExtractor()));
                    NMock2.Expect.Once.On(settings).Method("Initialize");
                    NMock2.Expect.Once.On(settings).GetProperty("WorkerCount").Will(NMock2.Return.Value(1));


                    using (Eas.WebCrawler.Model.WebCrawlerFactory.Create(settings)) { }
                }
                finally {
                    mockery.VerifyAllExpectationsHaveBeenMet();
                }

            }

        }

    }
}
